<main class="lyear-layout-content">

  <div class="container-fluid p-t-15">
    <span class="layui-breadcrumb">
      <a href="">首页</a>
      <a href="">数据统计</a></a>
      <a><cite>用户统计</cite></a>
    </span>
    <div class="row">
      <div class="col-lg-6">
        <div class="card">
          <div class="card-header">
            <h4>性别</h4>
          </div>
          <div class="card-body">
            <canvas id="chart-pie" width="280" height="280"></canvas>
          </div>
        </div>
      </div>
      <div class="col-lg-6">
        <div class="card">
          <div class="card-header">
            <h4>认证状态</h4>
          </div>
          <div class="card-body">
            <canvas id="chart-doughnut" width="280" height="280"></canvas>
          </div>
        </div>
      </div>
    </div>

  </div>

</main>

<script>
  $.ajax({
    type: 'post',
    url: `{:url('admin/analysis/user')}`,
    data: {
      action: 'pie'
    },
    dataType: 'json',
    success: function (res) {
      new Chart($('#chart-pie'), {
        type: 'pie',
        data: {
          labels: ["男", "女", "保密"],
          datasets: [{
            data: res.data.sex,
            backgroundColor: ['rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)']
          }]
        }
      })

      new Chart($('#chart-doughnut'), {
        type: 'pie',
        data: {
          labels: ["未认证", "认证"],
          datasets: [{
            data: res.data.auth,
            backgroundColor: ['rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)']
          }]
        }
      })

    }
  })
</script>